package com.commerce.service.impl;

import com.commerce.common.Reminder;
import com.commerce.mapping.ClassifyMapping;
import com.commerce.model.Classify;
import com.commerce.service.ClassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

@Service
public class ClassifyServiceImpl implements ClassifyService {

    @Autowired
    private ClassifyMapping classifyMapping;

    /**
     * 新增
     *
     * @param classify
     * @param request
     * @return
     */
    @Override
    public String insert(Classify classify, HttpServletRequest request) {
        return classifyMapping.insert(classify)>0?Reminder.success.getName():Reminder.saveerror.getName();
    }

    /**
     * 修改
     *
     * @param classify
     * @param request
     * @return
     */
    @Override
    public String update(Classify classify, HttpServletRequest request) {
        return classifyMapping.update(classify)>0?Reminder.success.getName():Reminder.updateerror.getName();
    }

    /**
     * 根据ID删除
     *
     * @param id
     * @return
     */
    @Override
    public String deleteById(int id) {
        return classifyMapping.deleteById(id)>0?Reminder.success.getName():Reminder.deleteerror.getName();
    }

    /**
     * 根据ID查询
     *
     * @param id
     * @return
     */
    @Override
    public Classify selectById(int id) {
        return classifyMapping.selectById(id);
    }
}
